<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>通知管理 | {$system_name??''}</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="icon" type="image/png" href="{_ADMIN_STATIC_}/i/favicon.png">
    <!-- <link rel="apple-touch-icon-precomposed" href="{_ADMIN_STATIC_}/i/app-icon72x72@2x.png"> -->
    <link rel="stylesheet" href="{_ADMIN_STATIC_}/css/amazeui.min.css" />
    <link rel="stylesheet" href="{_ADMIN_STATIC_}/css/admin.css">
    <link rel="stylesheet" href="{_ADMIN_STATIC_}/css/app.css">
    <!-- <script src="{_ADMIN_STATIC_}/js/echarts.min.js"></script> -->

</head>

<body data-type="index">
    <!-- 头部导航栏 -->
    {include file='public/header'}
    <!-- 左侧侧边栏 -->
    {include file='public/side'}
    <!-- 中间内容开始 -->

    <!-- 标题 -->
    <div class="tpl-content-page-title">
        {$system_name} -- 通知管理
    </div>
    <!-- 面包屑导航 -->
    <ol class="am-breadcrumb">
        <li><i class="am-icon-home"></i>通知管理首页</a></li>
    </ol>
    <!-- 提示信息 -->
    <div class="tpl-content-scope">
        <div class="note note-info">
            <h3> 通知管理起始页
                <span class="close" data-close="note"></span>
            </h3>
            <p>该页面涵盖了通知的所有信息以及功能</p>
            <p><span class="label label-danger">提示:</span>
                当前页面为通知管理的主要页面
            </p>
        </div>

        <div class="tpl-portlet-components">
            <div class="am-btn-group am-btn-group-xs">
                <button type="button" class="am-btn am-btn-default am-btn-success" onclick="notice_add()"><span
                        class="am-icon-plus"></span>
                    新增</button>
            </div>

            <table class="am-table am-table-striped am-table-hover table-main">
                <thead>
                    <tr>
                        <th class="table-id">#</th>
                        <th class="table-title">标题</th>
                        <th class="table-type">创建者</th>
                        <th class="table-author">创建时间</th>
                        <th style="width: 100px;">是否置顶</th>
                        <th style="width: 100px;">是否显示</th>
                        <th class="table-set" style="width: 160px;">操作</th>
                    </tr>
                </thead>
                <tbody>
                    {volist name="notice_list" id="row"}
                    <tr>
                        <td>{$row.id}</td>
                        <td>{$row.title}</td>
                        <td>{$row.admin_name}</td>
                        <td>{$row.create_time | date="Y-m-d H:i:s"}</td>
                        <td>
                            {if condition="$row.is_top == 1"}
                            <span style="color: green;">
                                {$row.is_top | notice_is_top_status}
                            </span>
                            {else /}
                            <span style="color: red;">
                                {$row.is_top | notice_is_top_status}
                            </span>
                            {/if}
                        </td>
                        <td>
                            {if condition="$row.display == 1"}
                            <span style="color: green;">
                                {$row.display | notice_display_status}
                            </span>
                            {else /}
                            <span style="color: red;">
                                {$row.display | notice_display_status}
                            </span>
                            {/if}
                        </td>
                        <td>
                            <div class="am-btn-toolbar">
                                <div class="am-btn-group am-btn-group-xs">
                                    <button class="am-btn am-btn-default am-btn-xs am-text-secondary"
                                        onclick="notice_edit('{$row.id}')"><span class="am-icon-pencil-square-o"></span>
                                        编辑</button>
                                    <button class="am-btn am-btn-default am-btn-xs am-text-danger am-hide-sm-only"
                                        onclick="notice_del('{$row.id}')"><span class="am-icon-trash-o"></span>
                                        删除</button>
                                </div>
                            </div>
                        </td>
                    </tr>
                    {/volist}
                </tbody>
            </table>
            <!-- 加载分页组件 -->
            {include file="public/page"}

        </div>
    </div>
    <!-- 中间内容结束 -->
    <!-- 底部 -->
    <!-- {include file="public/footer"} -->

    <script src="{_ADMIN_STATIC_}/lib/jquery/jquery.js"></script>
    <script src="{_ADMIN_STATIC_}/js/amazeui.min.js"></script>
    <script src="{_ADMIN_STATIC_}/js/iscroll.js"></script>
    <script src="{_ADMIN_STATIC_}/js/app.js"></script>
    <script src="{_ADMIN_STATIC_}/lib/layer/layer.js"></script>

    <script>

        // 添加资讯
        function notice_add() {
            layer.full(
                layer.open({
                    type: 2,
                    title: '添加一条通知',
                    shadeClose: true,
                    maxmin: true,
                   area: ['893px', '800px'],
                    content: "{:url('Notice/add')}",
                    end: function () {
                        location.reload();
                    }
                })
            );
        }

        // 编辑资讯
        function notice_edit(nid) {
            layer.full(
                layer.open({
                    type: 2,
                    title: '编辑一条通知',
                    shadeClose: true,
                    maxmin: true,
                   area: ['893px', '800px'],
                    content: "{:url('Notice/edit')}?nid=" + nid,
                    end: function () {
                        location.reload();
                    }
                })
            );
        }

        // 删除资讯
        function notice_del(nid) {
            
            layer.confirm('是否确认删除？', {
                btn: ['是', '否'] //按钮
            }, function () {
                $.ajax({
                    url: "{:url('Notice/del')}",
                    data: {
                        'id': nid
                    },
                    type: "POST",
                    dataType: "JSON",
                    async: true,
                    success: function (res) {
                        // 返回结果处理
                        if (res.code == 0) {
                            return layer.msg(res.msg, { icon: 1, time: 900 },function(){
                                location.reload();
                            });
                        } else {
                            return layer.msg(res.msg, { icon: 2, time: 900 });
                        }
                    }
                });
            }, function () { });

        }

    </script>


</body>

</html>